{% extends 'base.html' %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{#{% load martortags %}#}

<!--
{#{% block csslink %}#}
{#    <link href="{% static 'plugins/css/ace.min.css' %}" type="text/css" media="all" rel="stylesheet"/>#}
{#    <link href="{% static 'plugins/css/semantic.min.css' %}" type="text/css" media="all" rel="stylesheet"/>#}
{#    <link href="{% static 'plugins/css/resizable.min.css' %}" type="text/css" media="all" rel="stylesheet"/>#}
{#    <link href="{% static 'martor/css/martor.min.css' %}" type="text/css" media="all" rel="stylesheet"/>#}
{#{% endblock %}#}
-->

{% block csslink %}
    <!-- Font Awesome -->
    <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"
          integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
    <!-- Tempus Dominus Bootstrap 4 -->
    <link rel="stylesheet" href="{% static 'basicinfo/css/tempusdominus-bootstrap-4.min.css' %}"/>
{% endblock %}

{% block script %}
    <script type="text/javascript">
        {#$.fn.bsModal = $.fn.modal.noConflict(); // 解决bootstrap和semantic中modal控件冲突,定义后bootstrap的modal方法使用bsModal替代#}
    </script>

    <script src="{% static 'logs/js/common_logs.js' %}"></script>
    <script src="{% static 'logs/js/day_of_week.js' %}"></script>
    {{ form.media }}
{% endblock script %}

{% block style %}
    <style>
        div.input-group.date + p.invalid-feedback {
            display: block; // TimePickerInput控件显示错误提示
        }
    </style>

{% endblock %}

{% block content %}
    <div class="row mb-4">
        <div class="col-md-4">
            {% if create_or_update == 1 %}
                <h2 class="t2">添加机房日志</h2>
            {% elif create_or_update == 2 %}
                <h2 class="t2">修改机房日志</h2>
            {% endif %}
        </div>

        <div class="col-md-4 mt-3">
            <div class="font-weight-light">
                日志日期：{{ log_date | date:'Y年m月d日' }}
                <span id="day-of-week" data-day-of-week={{ log_date | date:'w' }} class="m-1"></span>
                <strong style="color:blue">{% if time_slot == 1 %} 上午 {% else %} 下午 {% endif %}</strong>
            </div>
        </div>

        <div id="sign-in-div" class="col-md-4 mt-3">
            {% include 'logs/includes/common_log_form_sign_in.html' %}
        </div>
        <!-- modal-sign-in -->
        <div class="modal fade" id="modal-sign-in">
            <div class="modal-dialog">
                <div class="modal-content">
                </div>
            </div>
        </div>
    </div>
    <form method="post" novalidate="novalidate">
        {% csrf_token %}
        {{ form.field_errors }}
        {% if form.non_field_errors %}
            <div class="alert alert-danger text-center align-content-center" role="alert">
                {% for error in form.non_field_errors %}
                    <p{% if forloop.last %} class="mb-0"{% endif %}>{{ error }}</p>
                {% endfor %}
            </div>
        {% endif %}
        <div class="form-row">
            <div class="form-group col-md-6 mb-0">
                {{ form.weather|as_crispy_field }}
            </div>
            <div class="form-group col-md-6 mb-0">
                {{ form.log_time|as_crispy_field }}
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-md-6 mb-0">
                {{ form.lab_template|as_crispy_field }}
            </div>
            <div class="form-group col-md-6 mb-0">
                {{ form.lab_humidity|as_crispy_field }}
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-md-6 mb-0">
                {{ form.hc_room_template|as_crispy_field }}
            </div>
            <div class="form-group col-md-6 mb-0">
                {{ form.hc_room_humidity|as_crispy_field }}
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-md-6 mb-0">
                {{ form.network_delay|as_crispy_field }}
            </div>
            <div class="form-group col-md-6 mb-0">
                {{ form.packet_lose_rate|as_crispy_field }}
            </div>
        </div>

        <div class="form-row">
            <div class="col-md-12 mb-0">
                {{ form.description|as_crispy_field }}
            </div>
        </div>
        <div class="form-row">
            <div class="col-md-12 mb-4">
                {% if create_or_update == 1 %}
                    <button type="submit" class="btn btn-primary">添加</button>
                {% elif create_or_update == 2 %}
                    <button type="submit" class="btn btn-primary">修改</button>
                {% endif %}
                <button type="reset" class="btn btn-outline-primary">重置</button>
            </div>
        </div>
    </form>
{% endblock content %}
